package cn.dubito.miaosha.service;

import cn.dubito.miaosha.dao.UserDao;
import cn.dubito.miaosha.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author liliang
 * @description:
 * @date 2018/3/28.
 */
@Service
public class UserService {

    @Autowired
    private UserDao userDao;

    public User getById(Integer id){
        return userDao.getById(id);
    }

    @Transactional(rollbackFor = Exception.class)
    public void testTx() {
        User user = new User();
        user.setId(4);
        user.setName("nsdf 地方");
        userDao.insert(user);
        user.setId(1);
        user.setName("ssssdddd");
        userDao.insert(user);
    }
}
